<style lang="scss" scoped>
.management-channel{
    width:100%;
    @import  '../index.scss';
    .btn-box{
        width:100%;
        height:auto;
        display:flex;
        margin-bottom:20px;
        .btn{
            width:100px;
            line-height:40px;
            text-align:center;
            margin-right:10px;
            outline:none;
            border:0;
            color:#fff;
            background:#d15b47;
            cursor:pointer;
        }
        .btn1{
            background-color: #428bca
        }
        .btn2{
            background-color: #ffb752
        }
    }
    .ivu-page{
        margin:20px 0;
    }
    
    .handel-date{
        .ivu-form-item-required{
            margin-right:0
         }

    }
    
}
    
</style>

<template>
    <div class="management-channel">
        <Card>
            
            <p slot="title" class="card-title">
                <span>商户通道变更审核</span>
            </p>
            <header>
                <div class="handel-content">
                    <Form ref="formValidate" :model="formValidate" :rules="ruleValidate" :label-width="90">
                        <div class="handel-details">
                            <FormItem label="商户名：" prop="name">
                                <Input v-model="formValidate.name" placeholder="请输入商户名"></Input>
                            </FormItem>
                            <!-- <FormItem label="姓名：" prop="mail">
                                <Input v-model="formValidate.mail" placeholder="请输入姓名"></Input>
                            </FormItem> -->
                            <FormItem label="商家状态：" prop="city">
                                <Select v-model="formValidate.city" placeholder="请选择">
                                    <Option value="beijing" >全部</Option>
                                    <Option value="shanghai">禁用</Option>
                                    <Option value="shenzhen">启用</Option>
                                </Select>
                            </FormItem>
                            <FormItem label="新增时间:">
                                <div class="handel-date">
                                    <FormItem prop="date">
                                        <DatePicker type="date" placeholder="Select date" v-model="formValidate.date"></DatePicker>
                                    </FormItem>
                                    <div  class="line"> - </div>
                                    <FormItem prop="date">
                                        <DatePicker type="date" placeholder="Select date" v-model="formValidate.time"></DatePicker>
                                    </FormItem>
                                </div>
                            </FormItem>
                        </div>
                        
                        
                        <FormItem>
                            <Button type="primary" icon="ios-search">搜索</Button>
                            <!-- <Button type="primary" @click="handleSubmit('formValidate')">Submit</Button>
                            <Button @click="handleReset('formValidate')" style="margin-left: 8px">Reset</Button> -->
                        </FormItem>
                    </Form>
                    

                </div>

            </header>
            <!-- 
            <div class="btn-box">  
                <button :class="['btn', '', {'btn-info':false} ]" @click="changeActive($event)" index="0">禁用</button>
                <button :class="['btn', 'btn1', {'btn-info':false} ]" index="1"  @click="changeActive($event)">添加</button>
                <button :class="['btn', 'btn2', {'btn-info':false} ]" index="2"  @click="changeActive($event)">密码解锁</button>            
            </div>
             -->

            <Table border ref="selection" :columns="columns4" :data="data1">
            
                <template slot-scope="{ row, index }" slot="action">
                    <Button type="primary" size="small" style="margin-right: 5px" @click="show(index)">同意</Button>
                    <Button type="warning" size="small" style="margin-right: 5px"  @click="remove(index)">拒绝</Button>
                </template>
            </Table>

            <Page :total="data.total" class="tr" @on-change="pageChange" :current.sync="data.current" :page-size="data.size"
                      @on-page-size-change="pageSizeChange" show-elevator show-sizer></Page>
        </Card>

        
        
    </div>
</template>

<script>
// console.log($)
export default {
    name:'management_channel',
    data () {
            return {
                formValidate: {
                    name: '',
                    mail: '',
                    city: 'beijing',
                    gender: '',
                    interest: [],
                    date: '',
                    time: '',
                    desc: ''
                },
                ruleValidate: {
                    name: [
                        { required: true, message: 'The name cannot be empty', trigger: 'blur' }
                    ],
                    mail: [
                        { required: true, message: 'Mailbox cannot be empty', trigger: 'blur' },
                        { type: 'email', message: 'Incorrect email format', trigger: 'blur' }
                    ],
                    city: [
                        { required: true, message: 'Please select the city', trigger: 'change' }
                    ],
                    gender: [
                        { required: true, message: 'Please select gender', trigger: 'change' }
                    ],
                    interest: [
                        { required: true, type: 'array', min: 1, message: 'Choose at least one hobby', trigger: 'change' },
                        { type: 'array', max: 2, message: 'Choose two hobbies at best', trigger: 'change' }
                    ],
                    date: [
                        { required: true, type: 'date', message: 'Please select the date', trigger: 'change' }
                    ],
                    time: [
                        { required: true, type: 'string', message: 'Please select time', trigger: 'change' }
                    ],
                    desc: [
                        { required: true, message: 'Please enter a personal introduction', trigger: 'blur' },
                        { type: 'string', min: 20, message: 'Introduce no less than 20 words', trigger: 'blur' }
                    ]
                },
                columns4: [
                    {
                        type: 'selection',
                        width: 60,
                        align: 'center'
                    },
                    {
                        title: '商户名',
                        key: 'name'
                    },
                    {
                        title: '原通道',
                        key: 'age'
                    },
                    {
                        title: '申请通道',
                        key: 'address'
                    },
                    {
                        title: '申请时间',
                        key: 'address'
                    },
                    {
                        title: '代理商审核状态',
                        key: 'address',
                        // align: 'center'
                    },
                    
                    {
                        title: '操作',
                        slot: 'action',
                        width: 150,
                        align: 'center'
                    }
                ],
                 data1: [
                    {
                        name: 'John Brown',
                        age: 18,
                        address: 'New York No. 1 Lake Park',
                        date: '2016-10-03'
                    },
                    {
                        name: 'Jim Green',
                        age: 24,
                        address: 'London No. 1 Lake Park',
                        date: '2016-10-01'
                    },
                    {
                        name: 'Joe Black',
                        age: 30,
                        address: 'Sydney No. 1 Lake Park',
                        date: '2016-10-02'
                    },
                    {
                        name: 'Jon Snow',
                        age: 26,
                        address: 'Ottawa No. 2 Lake Park',
                        date: '2016-10-04'
                    }
                ],
                data: {},
                dataFilter:{
                    page:1,
                    pageSize:10
                }
            }
        },
        methods: {/**
             * @description 分页更换事件回调
             */
            pageChange(p){
                this.dataFilter.page = p;
                this.getData();
            },
            /**
             * @description 分页每页显示数量改变事件回调
             */
            pageSizeChange(p){
                this.dataFilter.pageSize = p;
                this.getData();
            },
            handleSubmit (name) {
                this.$refs[name].validate((valid) => {
                    if (valid) {
                        this.$Message.success('Success!');
                    } else {
                        this.$Message.error('Fail!');
                    }
                })
            },
            handleReset (name) {
                this.$refs[name].resetFields();
            },
            show(index){
                console.log(index)
            },
            remove(index){
                console.log(index)
                this.data1.splice(index, 1)
            }
        }
}
</script>